package com.xing.controller;

import com.xing.Utils.Result;
import com.xing.dto.BroadcastDTO;
import com.xing.service.BroadcastService;
import com.xing.utils.PageData;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @version 1.0
 * @Author Xing
 * @Date 2024/4/27 22:04
 */
@Tag(name = "直播记录")
@RestController
@RequestMapping("broadcast")
public class BroadcastController {
    @Autowired
    private BroadcastService service;

    @Operation(summary = "直播记录")
    @GetMapping("liveHistory")
    public Result GetLiveHistory(@RequestParam("page") Integer page, @RequestParam("limit") Integer limit) {
        PageData<BroadcastDTO> pageData = service.getLiveHistory(page, limit);
        return new Result().ok(pageData);
    }

    @Operation(summary = "删除记录")
    @DeleteMapping("{id}")
    public Result DeleteLiveHistory(@PathVariable("id") Long id) {
        Boolean del = service.DeleteLiveHistory(id);
        if (del) {
            return new Result().ok();
        }
        return new Result().err(611,"删除失败");
    }

    @Operation(summary = "添加直播记录")
    @GetMapping("beginLive")
    public Result beginLive(){
        return service.beginLive();
    }


    @Operation(summary = "结束直播")
    @GetMapping("endLive")
    public Result endLive(){
        return service.endLive();
    }


}
